#include <stdio.h>
#include <stdlib.h>

void schitalka(int n, int k)    
{
	int a[1000], i, j, p, nn, b;
	for (i=0; i<n; i++)
	{
		a[i]=i+1;
	}
	p=0;
	nn=n;
	for (i=0; i<n-1; i++)
	{
		p=(p+(k%nn));
		if (p>nn)
		{
			p=p%nn;
		}
		nn=nn-1;
		p=p-1;
		if (p<0)
			{
				p=nn+p+1;
			}
		printf("%d ", a[p]);

		for (j=p; j<nn; j++)
		{
			b=a[j];
			a[j]=a[j+1];
			a[j+1]=b;
		}
	}
	printf("winner ");
	printf("%d ", a[0]);
}

void main()
{
printf("vvedite kol-vo ludei v kruge i kol-vo slov v schitalke\n");
	int K, N, check;
	check=scanf("%d", &N);
	if (check!= 1){
		printf("vse ploxo\n");
		return;
		system ("PAUSE");
	}
	check=scanf("%d", &K);
	if (check!= 1){
		printf("vse ploxo\n");
		return;
		system ("PAUSE");
	}
	schitalka (N, K);
	system ("PAUSE");
}